/**
 * Created by zhangsi on 2015/11/3.
 */
var handlerCtrl = new XFApp.client();
XFApp.client.prototype.todo = {
    isSubmitting : false,
    successCode : 10000,
    urlItems : {
        handleUrl : basePath +"/workflow/ajax/completeTask",
        todoListUrl : basePath +"/workflow/todo"
    },
    submitDialog : function(){
        webDialogUtil.simpleConfrimAlert("提交审批意见",
            function(){handlerCtrl.todo.submit();});
    },
    submit : function(){
        var _this = this;
        $.ajax({
            url:_this.urlItems.handleUrl,
            data:$('#editForm').serialize(),
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.code == _this.successCode){
                    webDialogUtil.callbackConfrimAlert(data.msg, function(){
                        window.location = handlerCtrl.todo.urlItems.todoListUrl
                    });
                }else{
                    webDialogUtil.simpleAlert(data.msg);
                }
            },
            error : function() {
                webDialogUtil.simpleAlert("删除用户失败，请刷新后重试!");
            }
        });
    },
    event : function(){
        var _this = this;
        $("#submitBtn").on("click", function(){
            _this.submit();
        });
    }
}

$(function(){
    handlerCtrl.todo.event();
});